package General;

import java.sql.*;
import java.util.ArrayList;

import javax.swing.*;

import Database.*;
import Exception.*;
import GenericClass.*;

import com.toedter.calendar.*;

public class CreaModPanel extends JPanel
{
	protected ArrayList<String> arrayColumn;
	protected CallDB callDB;
	protected Connection connection;
	protected MyTableModel myRightTableModel, courseListModel;
	protected JTable tableRight;
	private FormatScrollPane formatScrollPane;

	protected JScrollPane scrollTable;
	protected JButton buttonAdd, buttonSuppress, buttonDone;
	protected JButton buttonBack;
	protected JButton buttonSummary;
	
	private JLabel labelName;
	protected JLabel labelDate;
	protected JTextField fieldName;
	
	protected JDateChooser date;

	public CreaModPanel(CallDB callDB, Connection connection) throws CheckDataException, FormatScrollPaneException
	{
		setLayout(null);
		
		this.callDB = callDB;
		this.connection = connection;
		this.formatScrollPane = new FormatScrollPane();

		creationSuperComponent();
		showSuperComponent();
	}
	
	protected void refreshSuperRightTable() throws FormatScrollPaneException
	{
		formatScrollPane.autoFillScrollPane(tableRight, myRightTableModel, GeneralMethod.getArrayRightHeader(), scrollTable, "multiple", true, true, true, false);
		validate();
	}
	
	public void creationSuperComponent() throws CheckDataException, FormatScrollPaneException
	{		
		tableRight = new JTable();
		
		scrollTable = new JScrollPane();
		scrollTable.setBounds(410, 57, 330, 303);
		
		date = GraphicsSetting.dateCreate();

		labelName = new JLabel("Name");
		labelName.setHorizontalAlignment(SwingConstants.LEFT);
		
		fieldName = new JTextField("");
		fieldName.setColumns(10);
		fieldName.setHorizontalAlignment(SwingConstants.LEFT);

		labelDate = new JLabel("Date");
		labelDate.setHorizontalAlignment(SwingConstants.LEFT);
		
		buttonDone = new JButton("Done");
		buttonAdd = new JButton("Add");
		buttonSuppress = new JButton("Suppress");
		buttonSummary = new JButton("Summary");
		buttonBack = new JButton("Back");
	}
	
	public void showSuperComponent()
	{
		labelName.setBounds(40, 57, 55, 30); fieldName.setBounds(115, 57, 175, 30);
		
		buttonBack.setBounds(40, 422, 330, 45); buttonDone.setBounds(410, 422, 330, 45);
		
		this.add(labelName); this.add(fieldName);
		
		this.add(scrollTable);
		this.add(buttonBack); this.add(buttonDone);
	}

	public JButton getButtonBack(){return buttonBack;}
	public JTextField getFieldName(){return fieldName;}
	public JButton getButtonDone(){return buttonDone;}
	public JScrollPane getStudentTable(){return scrollTable;}
	public JButton getButtonAdd(){return buttonAdd;}
	public JButton getButtonSuppress(){return buttonSuppress;}
}